package org.sokula.sun.service.meta;

import org.apache.commons.lang.builder.ToStringBuilder;

/**
 * 
 * @author dong.yaojd
 * 
 * @version $Id: $
 */
@SuppressWarnings("unchecked")
public class ReturnInfo {

	private Class type;

	private String typeName;

	public Class getType() {
		return type;
	}

	public void setType(Class type) {
		this.type = type;
		this.typeName = this.type.getName();
	}

	public boolean isVoid() {
		if ("void".equals(typeName)) {
			return true;
		}
		return false;
	}

	public Object getDefaultValue() {
		if (int.class.equals(type) || Integer.class.equals(type)) {
			return new Integer(-1);
		} else if (long.class.equals(type) || Long.class.equals(type)) {
			return new Long(-1);
		} else if (double.class.equals(type) || Double.class.equals(type)) {
			return new Double(-1);
		} else if (boolean.class.equals(type) || Boolean.class.equals(type)) {
			return Boolean.TRUE;
		} else if (float.class.equals(type) || Float.class.equals(type)) {
			return new Float(-1);
		} else{
			return null;
		}
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this).append("void", this.isVoid()).append(
				"type", this.type).toString();
	}
}
